package com.example.redcultural;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import org.json.JSONObject;

public class MainActivity extends AppCompatActivity {

    BottomNavigationView bottomNavigationView;
    LinearLayout content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().setStatusBarColor(Color.argb(30, 255, 255, 255));
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            getWindow().setNavigationBarColor(Color.WHITE);

            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                    View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR |
                    View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR |
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE);


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bottomNavigationView = findViewById(R.id.design_navigation_view);
        FragmentManager fragmentManager = getFragmentManager();
        tour one = new tour();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.neiron, one);
        transaction.commit();
        //Toast.makeText(MainActivity.this,new NewsGet().get("top"),Toast.LENGTH_LONG).show();
        //Log.e("sss",new NewsGet().get("top"));
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
                //AnotherRightFragment fragment = new AnotherRightFragment()
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction transaction = fragmentManager.beginTransaction();
                tour one = new tour();
                story two = new story();
                study three = new study();
                //transaction.replace(R.id.right_layout, fragment);
                switch (menuItem.getItemId()) {
                    case R.id.action_1:
                        transaction.replace(R.id.neiron, one);
                        transaction.commit();
                        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE |
                                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                                View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR |
                                View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR |
                                View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
                        return true;
                    case R.id.action_2:
                        transaction.replace(R.id.neiron, two);
                        transaction.commit();
                        return true;
                    case R.id.action_3:
                        transaction.replace(R.id.neiron, three);
                        transaction.commit();
                        return true;
                }
                return false;
            }
        });
    }


}
